﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Chapter21
{
    using Chapter21.View;
    using Chapter21.ViewModel;

    /// <summary>
    /// 第21章 数据视图
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            #region 01 View 对象
            /*
             * 01 检索视图对象
             * 02 视图导航
             * 03 以声明方式创建视图
             * */
            #endregion

            #region 02 过滤、排序与分组
            /*
             * 01 过滤集合
             * 02 过滤 DataTable 对象
             * 03 排序
             * 04 分组 
             * 04.01 范围分组
             * 04.02 分组和虚拟化
             * 04.05 实时成型
             * */
            #endregion

            #region 03 小结
            #endregion
        }

        private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Command == ApplicationCommands.Open)
            {
                if ((Button)e.Source == button1)
                {
                    Demo(new NavigateCollectionWindow());
                }
                if ((Button)e.Source == button2)
                {
                    Demo(new NavigateCollection2Window());
                }
                if ((Button)e.Source == button3)
                {
                    Demo(new ItemsFilterWindow());
                }
                if ((Button)e.Source == button4)
                {
                    Demo(new ItemsGroupWindow());
                }
                if ((Button)e.Source == button5)
                {
                    Demo(new ItemsGroup2Window());
                }
                if ((Button)e.Source == button6)
                {
                    Demo(new ItemsGroup3Window());
                }
                if ((Button)e.Source == button7)
                {
                    Demo(new ItemsLiveWindow());
                }
            }
        }

        private void Demo(Window window)
        {
            window.Owner = this;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.ShowDialog();
        }
    }
}
